import json

from botocore.config import Config

from service.EverDB import EverDB
import os

# 判断tmp文件夹是否存在 不存在就创建
if not os.path.exists("./tmp"):
    os.mkdir("./tmp")

db = EverDB("1", "1")
cache = EverDB("local", "2", {"path": "./tmp/cache_db.lmdb"})

# try:
#     with open("config.json", "r", encoding="utf-8") as f:
#         config = json.load(f)
#     print("配置加载成功:", config)
# except FileNotFoundError:
#     print("配置文件未找到，请检查路径！")
# except json.JSONDecodeError as e:
#     print("配置文件格式错误:", e)


# db.init_S3(config["oss"])

# 本地
db.init_S3(
    {
        "endpoint": "http://127.0.0.1:9000",
        "key_id": "minioadmin",
        "access_key": "minioadmin",
        "verify": False,
        "use_ssl": False,
    }
)

# 绿区
# db.init_S3(
#     {
#         "endpoint": "http://10.13.13.182:30002",
#         "key_id": "Minio@admin",
#         "access_key": "rX6sW5zJ6kX8",
#         "verify": False,
#         "use_ssl": False,
#     }
# )

# osdev
# db.init_S3({
#     "endpoint": "http://osdev.xuelangyun.com:30102",
#     "key_id": "Minio@xuelang",
#     "access_key": "Minio@xuelang",
#     "verify": False,
#     "use_ssl": False
# })

# 红区oss
# db.init_S3(
#     {
#         "endpoint": "http://ossa92a-cn-shanghai-comac-d01-a.res.n01.cloud.comac.intra",
#         "key_id": "1CTVGgwmFYzLyQRx",
#         "access_key": "V3GODFH02rLqX7xqUOfgP1Wvt40nws",
#         "verify": False,
#         "use_ssl": False,
#         "region_name": "cn-north-1",
#     }
# )

# 红区minio
# db.init_S3(
#     {
#         "endpoint": "http://10.210.153.106:30016",
#         "key_id": "Minio@admin",
#         "access_key": "rX6sW5zJ6kX8",
#         "verify": False,
#         "use_ssl": False,
#     }
# )
